package com.ncbee.base.service.serviceimpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ncbee.base.dao.BaseDataDao;
import com.ncbee.base.model.entity.BaseData;
import com.ncbee.base.model.vo.TreeVo;
import com.ncbee.base.service.BaseDataService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author youdianyun
 * @since 2018-12-05
 */
@Service
public class BaseDataServiceImpl extends ServiceImpl<BaseDataDao, BaseData> implements BaseDataService {

    @Override
    public List<TreeVo> findBaseDataTree() {
        return baseMapper.queryAllBaseDataTree();
    }

    @Override
    public String getBaseDataValueByNodeCode(String nodeCode) {
        //构造查询条件
        QueryWrapper<BaseData> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("node_code",nodeCode);
        BaseData baseData=baseMapper.selectOne(queryWrapper);
        if(baseData==null){
            return null;
        }
        return baseData.getValue();
    }
}
